package com.tjbank.cssys.web.service.impl;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tjbank.cssys.domain.CkCreditOutCompanyDataLog;
import com.tjbank.cssys.repository.CkCreditOutCompanyDataLogMapper;
import com.tjbank.cssys.web.service.CkCreditOutCompanyDataLogService;
import com.tjbank.cssys.web.util.DateUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CkCreditOutCompanyDataLogServiceImpl implements CkCreditOutCompanyDataLogService {

    private static final Logger logger = LoggerFactory.getLogger(CkCreditOutCompanyDataLogServiceImpl.class);

    @Autowired
    private CkCreditOutCompanyDataLogMapper ckCreditOutCompanyDataLogMapper;

    /*高淙博  --- 获取对账佣金案件列表*/
    @Override
    public PageInfo SelectReconciliationCommissionList(Map<String, Object> map) {
        int page = Integer.parseInt(map.getOrDefault("page", "1").toString());
        int pageSize = Integer.parseInt(map.getOrDefault("pageSize", "10").toString());
        PageHelper.startPage(page, pageSize);
        List<Map<String, Object>> ckCreditOutCompanyDataLogs = ckCreditOutCompanyDataLogMapper.selectReconciliationCommissionList(map);
        PageInfo<Map<String, Object>> mapPageInfo = new PageInfo<>(ckCreditOutCompanyDataLogs);
        return mapPageInfo;
    }

    @Override
    public List<Map<String, Object>> getCompanys(String batchNumber) {

        logger.info("---查询有待对账的委外公司start---params：" + batchNumber);
        Map<String,String> params = new HashMap<String,String>();

        String preBatchNumber = DateUtils.getPreBatchNumber();
        if(null==batchNumber || StringUtils.isBlank(batchNumber)){
            batchNumber = preBatchNumber;
        }
        params.put("batchNumber", batchNumber);
        List<Map<String, Object>> resultMap = ckCreditOutCompanyDataLogMapper.getUnChenckCompanys(params);
        logger.info("------查询有待对账的委外公司end---result:" + JSON.toJSONString(resultMap));
        return resultMap;
    }
}
